package com.haiyou.common.spring.controller;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;

import com.haiyou.common.constants.ErrCode;
import com.haiyou.common.http.HttpResult;
import com.haiyou.common.http.HttpResultUtils;



/**
 * 
 * 
 * @Description: 自定义http 错误返回
 * @author xingyuan
 * @date 2022年3月24日 上午10:29:29
 */
@RestController
public class HttpErrorController implements ErrorController{

	/**
	 * 404 消息体
	 */
	public static final HttpResult ERROR_404 = HttpResultUtils.failResult(ErrCode.ERROR_PARAMETER,"404");
	
    private static final String ERROR_PATH = "/error";

    @RequestMapping(value = ERROR_PATH)
    @ResponseStatus(value = HttpStatus.NOT_FOUND)
    public HttpResult handleError() {
        return ERROR_404;
    }
}
